home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / c / MemPools.readme < prev    next >
Text File  |  1994-12-18  |  7KB  |  176 lines

  1. Short:    Malloc() replacement using Exec pools
  2. Author:   jochen.wiedmann@uni-tuebingen.de
  3. Uploader: jochen.wiedmann@uni-tuebingen.de
  4. Type:     dev/c
  5.  
  6.  
  7. MemPools - malloc() replacement using standard Exec memory pools
  8. ================================================================
  9.  
  10.  
  11. Many people don't like using malloc() and similar functions because
  12. they think it's too slow and gives too much overhead. Well, as far as
  13. I can say they're alright, at least for users of Dice and SAS/C:
  14. the Exec pool functions seem to be at least 5 times faster and it
  15. can even be faster than the malloc() of GNU-c! (See "Timings" below.)
  16.  
  17. Other people like malloc(): It's portable and rather easy to use.
  18. I am one of these, however I don't want to loose the speed of
  19. pool functions.
  20.  
  21. The mempools package is a link library with the functions malloc(),
  22. calloc(), realloc(), strdup() and free(). It replaces the compilers
  23. own functions by just linking against this library. No additional
  24. work is required as the library takes use of the compilers auto-
  25. initialization facility.
  26.  
  27. Ths autoinitialization restricts use of the mempools library to
  28. users of Dice, SAS/C and gcc: I don't know how to handle other
  29. compilers.
  30.  
  31. Note, that pools are available not only for users of OS 3.x! The
  32. current amiga.lib offers replacements which call exec.library,
  33. if the OS is 3.x and emulate pools otherwise. The MemPools
  34. library uses this replacements.
  35.  
  36.  
  37. 1.) Disclaimer: Copyrights, (No) Warranty
  38. -----------------------------------------
  39.  
  40. This program is Copyright (C) 1994  Jochen Wiedmann
  41.                     Am Eisteich 9
  42.                     72555 Metzingen
  43.                     Germany
  44.  
  45.                     Phone: (0049) +7123 / 14881
  46.                     Mail: jochen.wiedmann@uni-tuebingen.de
  47.  
  48.  
  49. Permission is granted to make and distribute either verbatim and modified
  50. copies of this documentation and the library MemPools provided the copyright
  51. notice and this permission notice are preserved on all copies and the "GNU
  52. General Public License" (in the file COPYING) is distributed as well.
  53.  
  54. The author gives ABSOLUTELY NO warranty that the software described in this
  55. documentation and the results produced by them are correct. The author
  56. cannot be held responsible for ANY damage resulting from the use of this
  57. software.
  58.  
  59.  
  60. 2.) Installation
  61. ----------------
  62.  
  63. There are four libraries included in the distribution, it depends
  64. on your compiler which one you need: mempoolss.lib and mempoolssr.lib
  65. are for dice, they should be copied to DLIB: or a similar place.
  66. mempools.lib is for SAS/C, its destination is sc:lib. Finally
  67. libmempools.a is the GNU-c version which should go to GNU:lib.
  68.  
  69. If you want to recreate them, just type smake (SAS/C) or make (GNU-c).
  70. Dice, however, requires different libraries, depending on the data
  71. model, the type of argument handling and so on.
  72.  
  73. To create a certain library just type
  74.  
  75.     lbmake mempools s        (for mempoolss.lib)
  76.     lbmake mempools s r        (for mempoolssr.lib)
  77.     lbmake mempools l        (for mempoolsl.lib)
  78.         .
  79.         .
  80.         .
  81.  
  82.  
  83. 3.) Usage
  84. ---------
  85.  
  86. All you have to do is to link against the mempools library.
  87.  
  88. a) Dice
  89.  
  90.     Add the option -lmempools to your compiler statement. By adding
  91.     it to the environment variable "DCCOPTS" you get this automatically.
  92.  
  93. b) SAS/C
  94.  
  95.     Add the option LIB mempools to your compiler statement. By using
  96.     the "scopts" program you can get this automatically, too.
  97.  
  98. c) gcc
  99.  
  100.     Add the option -lmempools to your compiler statement. I don't know
  101.     if gcc can handle this automatically. Probably someone can
  102.     enlighten me?
  103.  
  104. However, you might be interested in controlling the pools attributes.
  105. This can be done by creating global variables __MemPoolPuddleSize,
  106. __MemPoolThreshSize and __MemPoolFlags which correspond to the
  107. arguments of the CreatePool() function. For example, if you want
  108. to modify the puddle size (this can increase speed, see "Timings"
  109. below), just add the following line somewhere to your program:
  110.  
  111.     ULONG __MemPoolPuddleSize = 16384;    /*  Default: 4096    */
  112.  
  113. Or if you want malloc() to obtain chip memory, just write
  114.  
  115.     #include <exec/memory.h>
  116.     ULONG __MemPoolFlags = MEMF_CHIP;    /*  Default: MEMF_ANY    */
  117.  
  118.  
  119. 4.) Timings
  120. -----------
  121.  
  122. I wrote a little timing program. (I don't claim that it is very good,
  123. probably someone can write a better one.) I was rather surprised about
  124. the results:
  125.  
  126.     Compiler    Time (Mins:Secs)    Notes
  127.  
  128.     Dice    2:46,74         Dice maps malloc() to AllocMem()
  129.                     directly. This is extremely poor!
  130.                     Especially the exit() function
  131.                     needs about 20% of the programs
  132.                     time.
  133.  
  134.     SAS/C    1:17,66         SAS/C uses an own pool system.
  135.                     Thus the exit() function is
  136.                     rather fast. malloc(), however,
  137.                     seems to be slow.
  138.  
  139.     gcc     0:12,84 (ixemul)    gcc uses a pool system which is
  140.         0:14,34 (libnix)    rather close to Exec pools. This
  141.                     gives good results.
  142.  
  143.     MemPools    0:15,10 (4096)      By increasing the puddle size
  144.         0:12,14 (8192)      (see "Usage") you get better
  145.         0:10,80 (16384)     results! It seems worth to ry a
  146.                     little bit.
  147.  
  148.  
  149. ============================= Archive contents =============================
  150.  
  151. Original  Packed Ratio    Date     Time    Name
  152. -------- ------- ----- --------- --------  -------------
  153.     1693     904 46.6% 04-Dec-94 21:16:28  mempools/calloc.c
  154.    17982    6993 61.1% 01-Sep-93 18:40:30  mempools/COPYING
  155.     3051    1224 59.8% 05-Dec-94 04:27:36  mempools/DMakefile
  156.     1519     836 44.9% 04-Dec-94 18:22:16  mempools/free.c
  157.     2727    1229 54.9% 04-Dec-94 18:39:32  mempools/init.c
  158.     1337     572 57.2% 05-Dec-94 03:27:22  mempools/lib.def
  159.     3294    1059 67.8% 06-Dec-94 00:47:26  mempools/libmempools.a
  160.     2893    1163 59.7% 05-Dec-94 03:28:12  mempools/Makefile
  161.     1596     868 45.6% 04-Dec-94 21:24:48  mempools/malloc.c
  162.       59      59  0.0% 04-Dec-94 18:42:08  mempools/MemPoolFlags.c
  163.       60      60  0.0% 04-Dec-94 18:40:54  mempools/MemPoolPuddleSize.c
  164.     1916     828 56.7% 06-Dec-94 00:43:16  mempools/mempools.lib
  165.     5016    2246 55.2% 06-Dec-94 00:41:30  mempools/MemPools.readme
  166.     2688     985 63.3% 06-Dec-94 00:42:00  mempools/mempoolss.lib
  167.     2628     958 63.5% 06-Dec-94 00:42:40  mempools/mempoolssr.lib
  168.       59      59  0.0% 04-Dec-94 20:09:24  mempools/MemPoolThreshSize.c
  169.     1689     872 48.3% 04-Dec-94 21:15:56  mempools/realloc.c
  170.     2862    1164 59.3% 05-Dec-94 03:27:46  mempools/SMakefile
  171.     1491     819 45.0% 05-Dec-94 04:13:30  mempools/strdup.c
  172.     4480    1653 63.1% 05-Dec-94 03:50:44  mempools/TimeMem.c
  173.     2861    1308 54.2% 05-Dec-94 01:32:44  mempools/TimeProg.c
  174. -------- ------- ----- --------- --------
  175.    61901   25859 58.2% 07-Dec-94 18:33:10   21 files
  176.